﻿using System;
using System.Windows.Input;

namespace Wpf2.ViewModels
{
    public class MyCommands : ICommand
    {
        public Action<string> Action
        { get; set; }

        public MyCommands()
        {

        }

        public MyCommands(Action<string> action)
        {
            Action = action;
        }

        public bool CanExecute(object parameter)
        {
            if (Action != null)
            {
                return true;
            }

            return false;
        }

        public void Execute(object parameter)
        {
            if (Action != null)
            {
                Action(parameter.ToString());
            }
        }

        public event EventHandler CanExecuteChanged
        {
            add { CommandManager.RequerySuggested += value; }
            remove { CommandManager.RequerySuggested -= value; }
        }
    }
}
